#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Project  : seleniumGitee
# @File     : ecshop_login_backend.py
# @Author   : WanLiWei
# @Time     : 2021/7/1 23:22
# 引用unittest
import csv
import unittest
# 引用selenium中的webdriver
from selenium import webdriver
from time import sleep
from page.page_login import PageLogin
# 启动chrome浏览器，也是在实例化
# driver = webdriver.Chrome()
class Login(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        # 访问ecshop首页
    def test_login(self):
        # 利用csv文件读取内容
        # f = open(r"D:\git_root\seleniumGitee\data.csv","r",encoding="utf-8")
        # data = csv.reader(f)
        # for i in data:
        #     print(i)
        #     username,password = i[0],i[1]
        # 利用txt文件获取文件
        with open("D:\git_root\seleniumGitee\data.txt","r",encoding="utf-8") as f:
            data = f.readline().split(",")
                  # a= data[1].replace("\n","")
            username,password = data[0],data[1].replace("\n","")
        PageLogin(self.driver).login(username,password)
        sleep(5)
        # 登陆后台
        # self.driver.find_element_by_name("username").send_keys(username)
        # self.driver.find_element_by_name("password").send_keys(password)
        # self.driver.find_element_by_class_name("btn-a").click()
        # self.driver.find_element_by_xpath("")
        # 断言
    def tearDown(self):
        sleep(2)
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()